package org.smr.ministore.micro.client;

import org.blade.utils.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smr.ministore.entities.Brand;
import org.smr.ministore.entities.vo.Assign2OrganVO;
import org.smr.ministore.entities.vo.Assign2OrgansVO;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import feign.hystrix.FallbackFactory;


@Component
public class HystrixBrandClientFactory implements FallbackFactory<FeignBrandMicroServiceClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(HystrixBrandClientFactory.class);

    @Override
    public FeignBrandMicroServiceClient create(Throwable cause) {
        HystrixBrandClientFactory.LOGGER.info("fallback; reason was: {}", cause.getMessage());

        return new FeignBrandMicroServiceClient() {

            @Override
            public int batchSave(List<Brand> entities) {
                return -1;
            }

            @Override
            public int batchModify(List<Brand> entities) {
                return -1;
            }

            @Override
            public int save(Brand entity) {
                return -1;
            }

            @Override
            public int updateById(Brand id) {
                return -1;
            }

            @Override
            public Brand queryById(Long id) {
                Brand brand = new Brand();
                brand.setId(-1L);
                return brand;
            }

            @Override
            public int deleteById(Long id) {
                return -1;
            }

            @Override
            public Pager<Brand> paginate(Brand entity, Long pageSize, Long pageNum) {
                Pager<Brand> pager = new Pager<Brand>();
                pager.setTotalCount(-1L);
                return pager;
            }

            @Override
            public int assignToOrgans(Assign2OrgansVO assignee) {
                return -1;
            }

            @Override
            public int assign(Assign2OrganVO sssign2Organ) {
                return -1;
            }

        };//Return end
    }
}